<%today = Date.today.to_time%>
<%@upms = @project.upcoming_milestones%>
<%@up14ms = @project.upcoming_milestones_14%>
<%@upms_dues = @up14ms.collect{|m| m.due_at}%>
<%@today_ms = @up14ms.select{|m| m.due_at.to_date == today.to_date}%>

<!--UPCOMING start-->
<%if @today_ms.size > 0 or @upms.size > 0%>
<div id=upcoming_milestone>
<div class="milestone_label upcoming"> <%="Upcoming Milestone".t%> </div>
<%=render :partial=>'milestones/list_milestones',:locals=>{:milestones=>@today_ms}%>
<%if @up14ms.size>0%>
<%="Due in next 14 days".t%>
<table class=upcoming>
  <tr>
    <%0.upto(6) do |i|%>
    <th><%=i.days.since(today).strftime('%a').t%></th>
    <%end%>
  </tr>
  <tr>
    <td class=today><%="TODAY".t%>
      <%@today_ms.each do |m|%>
      <strong style="color:#600"><br/>><%=m.name%></strong>
       <%end%>
    </td>
    <%1.upto(6) do |i|%>
      <%due = i.days.since(today)%>
      <%if @upms_dues.include?(due)%>
         <%@upms_dues_td = @upms.select {|m| m.due_at == due}%>
         <td class=due><strong><%=due.strftime('%m-%d')%></strong><br/>
	 <%@upms_dues_td.each do |m|%>
	   ><%=m.name%><br/>
	 <%end%>
	 </td>
      <%else%>
         <td><%=i.days.since(today).strftime('%m-%d')%></td>
      <%end%>
    <%end%>
  </tr>
  <tr>
    <%0.upto(6) do |i|%>
      <%due = (7 + i).days.since(today)%>
      <%if @upms_dues.include?(due)%>
         <%@upms_dues_td = @upms.select {|m| m.due_at == due}%>
         <td class=due><strong><%=due.strftime('%m-%d')%></strong><br/>
	 <%@upms_dues_td.each do |m|%>
	   <%=m.name%><br/>
	 <%end%>
	 </td>
      <%else%>
         <td><%=(7 + i).days.since(today).strftime('%m-%d')%></td>
      <%end%>
    <%end%>
  </tr>
</table>
<%end%>
<%if @upms.size >0%>
<%="All Upcoming Milestones".t%>
<hr>
<%@upms.each do |milestone|%>
<div class="milestone_item upcoming_item">
<%="<strong>" + time_ago_in_words(milestone.due_at) + " later".t + "</strong>(" + milestone.due_at.strftime('%m/%d %Y') + ")"%>
<span class='intro_txt'> - <%=milestone.user.name if milestone.user%></span>
 <span class="private_label float_right"><%="Private".t if milestone.private%></span>
<h2>
 <span id='indi_<%=milestone.id%>' style="display:none"><%=image_tag"indicator.gif"%></span> 
<%=check_box_tag "ss","",false,{:onclick=>remote_function(:loading=>"Element.show('indi_#{milestone.id}')",:url=>{:controller=>'milestones',:action=>'finish',:id=>milestone.id,:project_id=>@project.id})}%><%=milestone.name%>
  <%=link_to"Edit".t,edit_milestone_path(milestone.project,milestone),:class=>'admin'%>
  <%=link_to image_tag("trash.gif",:border=>0),milestone_path(@project,milestone),:method=>'delete',:confirm=>"Are you sure?".t,:class=>'admin'%></h2>
</div>
<%end%>
<%end%>
</div>
<%end%>
